package com.hongxun.modules.bss.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.bss.dao.APRangeDao;
import com.hongxun.modules.bss.entity.APRangeEntity;
import com.hongxun.modules.bss.service.APRangeService;



@Service("aPRangeService")
public class APRangeServiceImpl implements APRangeService {
	@Autowired
	private APRangeDao aPRangeDao;
	
	@Override
	public APRangeEntity queryObject(String guid){
		return aPRangeDao.queryObject(guid);
	}
	
	@Override
	public List<APRangeEntity> queryList(Map<String, Object> map){
		return aPRangeDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return aPRangeDao.queryTotal(map);
	}
	
	@Override
	public void save(APRangeEntity aPRange){
		if(aPRange.getGuid()==null||aPRange.getGuid().equals("")) {

			aPRange.setGuid(UUID.randomUUID().toString());
		}
		aPRangeDao.save(aPRange);
	}
	
	@Override
	public void update(APRangeEntity aPRange){
		aPRangeDao.update(aPRange);
	}
	
	@Override
	public void delete(String guid){
		aPRangeDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		aPRangeDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<APRangeEntity> entities) {
		for (APRangeEntity d : entities) {
			if (d.getPRDatastate().equals("删除")) {
				aPRangeDao.delete(d.getGuid());
			} else {
				APRangeEntity apRangeEntity = aPRangeDao.queryObject(d.getGuid());
				if (apRangeEntity == null) {
					aPRangeDao.save(d);
				} else {
					aPRangeDao.update(d);
				}
			}
		}
	}
}
